package com.jchen.system.service.impl;

import com.jchen.common.util.R;
import com.jchen.minio.utils.MinioUtil;
import com.jchen.system.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description
 * @Author jchen
 * @Date 2023/12/8 16:37
 */
@Service
public class FileServiceImpl implements IFileService {

    @Autowired
    private MinioUtil minioUtil;

    @Override
    public R uploadFile(MultipartFile[] multipartFile) {
        List<String> names = new ArrayList<>();
        for (MultipartFile file : multipartFile) {
            String fileName = minioUtil.upload(file);
            //文件管理数据记录,收集管理追踪文件
            //fileLog(fileName,file);
            names.add(fileName);
        }
        return R.ok(names);
    }
}
